<template>
  <div class="mod-config">
    <el-form :inline="true">
      <el-form-item>
        <el-input v-model="dataForm.key" placeholder="姓名" clearable></el-input>
      </el-form-item>
      <el-form-item>
        <el-button @click="getDataList()">查询</el-button>
      </el-form-item>
    </el-form>
    <el-table
      :data="dataList"
      border
      v-loading="dataListLoading"
      @selection-change="selectionChangeHandle"
      style="width: 100%;">
      <el-table-column
        prop="userName"
        header-align="center"
        align="center"
        label="当班人">
      </el-table-column>
      <el-table-column
        prop="startTime"
        header-align="center"
        align="center"
        label="当班开始时间">
      </el-table-column>
      <el-table-column
        prop="endTime"
        header-align="center"
        align="center"
        label="交班时间">
      </el-table-column>
      <el-table-column
        prop="individualGuestNumber"
        header-align="center"
        align="center"
        label="散客消费人数">
      </el-table-column>
      <el-table-column
        prop="individualGuestMoney"
        header-align="center"
        align="center"
        label="散客消费金额">
		<template slot-scope="scope">
			<div style="color: red;font-weight: 500;">￥{{ scope.row.individualGuestMoney }}</div>
		</template>
      </el-table-column>
      <el-table-column
        prop="memberNumber"
        header-align="center"
        align="center"
        label="会员消费人数">
      </el-table-column>
      <el-table-column
        prop="memberMoney"
        header-align="center"
        align="center"
        label="会员消费金额">
		<template slot-scope="scope">
			<div style="color: red;font-weight: 500;">￥{{ scope.row.memberMoney }}</div>
		</template>
      </el-table-column>
      <el-table-column
        prop="memberRechargeMoney"
        header-align="center"
        align="center"
        label="会员充值金额">
		<template slot-scope="scope">
			<div style="color: red;font-weight: 500;">￥{{ scope.row.memberRechargeMoney }}</div>
		</template>
      </el-table-column>
      <el-table-column
        prop="accountUnitNumber"
        header-align="center"
        align="center"
        label="记账单位消费数">
      </el-table-column>
      <el-table-column
        prop="accountUnitMoney"
        header-align="center"
        align="center"
        label="记账单位消费金额">
		<template slot-scope="scope">
			<div style="color: red;font-weight: 500;">￥{{ scope.row.accountUnitMoney }}</div>
		</template>
      </el-table-column>
      <el-table-column
        prop="reserveNumber"
        header-align="center"
        align="center"
        label="预定餐台个数">
      </el-table-column>
      <el-table-column
        prop="reserveMoney"
        header-align="center"
        align="center"
        label="预定餐桌总押金">
		<template slot-scope="scope">
			<div style="color: red;font-weight: 500;">￥{{ scope.row.reserveMoney }}</div>
		</template>
      </el-table-column>
      <el-table-column
        prop="totalMoney"
        header-align="center"
        align="center"
        label="综合收入">
		<template slot-scope="scope">
			<div style="color: red;font-weight: 500;">￥{{ scope.row.totalMoney }}</div>
		</template>
      </el-table-column>
      <el-table-column
        prop="turnInCash"
        header-align="center"
        align="center"
        label="上缴现金">
		<template slot-scope="scope">
			<div style="color: red;font-weight: 500;">￥{{ scope.row.turnInCash }}</div>
		</template>
      </el-table-column>
      <el-table-column
        prop="devolutionCash"
        header-align="center"
        align="center"
        label="下放现金">
		<template slot-scope="scope">
			<div style="color: red;font-weight: 500;">￥{{ scope.row.devolutionCash }}</div>
		</template>
      </el-table-column>
      <el-table-column
        header-align="center"
        align="center"
        label="操作">
        <template slot-scope="scope">
          <el-button type="text" @click="changeWorkDetail(scope.row)">详情</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      @size-change="sizeChangeHandle"
      @current-change="currentChangeHandle"
      :current-page="pageIndex"
      :page-sizes="[10, 20, 50, 100]"
      :page-size="pageSize"
      :total="totalPage"
      layout="total, sizes, prev, pager, next, jumper">
    </el-pagination>

    <ChangeWork ref="ChangeWorkRef" v-if="ChangeWorkVisible"></ChangeWork>
  </div>
</template>

<script>
  import ChangeWork from './change-work-dialog'
  export default {
    data () {
      return {
        dataForm: {
          key: null
        },
        dataList: [],
        pageIndex: 1,
        pageSize: 10,
        totalPage: 0,
        dataListLoading: false,
        dataListSelections: [],
        addOrUpdateVisible: false,
        ChangeWorkVisible:false
      }
    },
    components: {
      ChangeWork
    },

    methods: {
      changeWorkDetail(row){
        this.ChangeWorkVisible = true
        this.$nextTick(() => {
          this.$refs.ChangeWorkRef.getData(row)
        })
      },

      // 获取数据列表
      getDataList () {
        this.dataListLoading = true
        this.$http({
          url: this.$http.adornUrl('/reception/tstorechangeworkrecord/list'),
          method: 'get',
          params: this.$http.adornParams({
            'page': this.pageIndex,
            'limit': this.pageSize,
            'key': this.dataForm.key
          })
        }).then(({data}) => {
          if (data && data.code === 0) {
            this.dataList = data.page.list
            this.totalPage = data.page.totalCount
          } else {
            this.dataList = []
            this.totalPage = 0
          }
          this.dataListLoading = false
        })
      },
      // 每页数
      sizeChangeHandle (val) {
        this.pageSize = val
        this.pageIndex = 1
        this.getDataList()
      },
      // 当前页
      currentChangeHandle (val) {
        this.pageIndex = val
        this.getDataList()
      },
    }
  }
</script>
